﻿// Decompiled with JetBrains decompiler
// Type: MCM.LightInject.FuncHelper
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;

#nullable disable
namespace MCM.LightInject
{
  [ExcludeFromCodeCoverage]
  internal static class FuncHelper
  {
    public static readonly MethodInfo CreateScopedFuncMethod = typeof (FuncHelper).GetTypeInfo().GetDeclaredMethod("CreateScopedFunc");
    public static readonly MethodInfo CreateScopedGenericFuncMethod = typeof (FuncHelper).GetTypeInfo().GetDeclaredMethod("CreateScopedGenericFunc");
    public static readonly MethodInfo CreateScopedGenericNamedFuncMethod = typeof (FuncHelper).GetTypeInfo().GetDeclaredMethod("CreateScopedGenericNamedFunc");

    public static Func<object> CreateScopedFunc(
      GetInstanceDelegate getInstanceDelegate,
      object[] constants,
      Scope scope)
    {
      return (Func<object>) (() => getInstanceDelegate(constants, scope));
    }

    public static Func<T> CreateScopedGenericFunc<T>(ServiceContainer serviceContainer, Scope scope)
    {
      return (Func<T>) (() => (T) serviceContainer.GetInstance(typeof (T), scope));
    }

    public static Func<string, T> CreateScopedGenericNamedFunc<T>(
      ServiceContainer serviceContainer,
      Scope scope)
    {
      return (Func<string, T>) (serviceName => (T) serviceContainer.GetInstance(typeof (T), scope, serviceName));
    }
  }
}
